package com.jyw.business.obstacles.wechat.controller;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jyw.business.obstacles.domain.vo.web.*;
import com.jyw.business.obstacles.domain.vo.wechat.WxOrderDailyDetailVO;
import com.jyw.business.obstacles.domain.vo.wechat.WxOrderDailyVO;
import com.jyw.business.obstacles.service.IObsOrderInfoService;
import com.jyw.common.core.controller.BaseController;
import com.jyw.common.core.domain.CommonResult;
import com.jyw.common.core.page.BasePage;
import com.jyw.common.core.page.TableDataInfo;
import com.jyw.common.utils.DateUtils;
import com.jyw.system.domain.dto.BaseTimeDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Api(tags = "首页")
@RestController
@RequestMapping("/wechat/obstacles/home")
public class WechatObsHomeController extends BaseController {

    @Resource
    private IObsOrderInfoService orderInfoService;

    @GetMapping("todo")
    @ApiOperation("我的待办事项(报障)")
    public CommonResult<HomeObsToDoVO> todo(){
        return CommonResult.success(orderInfoService.todo());
    }

    @GetMapping("mine/order")
    @ApiOperation("我的工单(数量)")
    public CommonResult<Integer> mineOrderNum(){
        return CommonResult.success(orderInfoService.mineOrderNum());
    }

    @GetMapping("mine/audit/order")
    @ApiOperation("工单审核(数量)")
    public CommonResult<Integer> mineAuditOrderNum(){
        return CommonResult.success(orderInfoService.mineAuditOrderNum());
    }

    @GetMapping("daily")
    @ApiOperation("日报(统计)")
    @ApiImplicitParam(name = "date",value = "统计日期 格式(yyyy-MM-dd)",required = true)
    public CommonResult<WxOrderDailyVO> daily(@JsonFormat(pattern = "yyyy-MM-dd")Date date){
        return CommonResult.success(orderInfoService.daily(date));
    }

    @GetMapping("daily/detail")
    @ApiOperation("日报(详情)")
    @ApiImplicitParam(name = "date",value = "统计日期 格式(yyyy-MM-dd)",required = true)
    public CommonResult<List<WxOrderDailyDetailVO>> dailyDetail(@JsonFormat(pattern = "yyyy-MM-dd")Date date){
        return CommonResult.success(orderInfoService.dailyDetail(date));
    }

}
